package com.dreamstations.changshads.util;

import com.dreamstations.changshads.entity.DatumBean;
import com.dreamstations.changshads.entity.LibraryBean;
import com.dreamstations.changshads.entity.ResourceBean;
import com.dreamstations.changshads.entity.WorkBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by QYH on 2016/6/4.
 * 单机版提供Bean的类，目的是取代从网络获取的操作
 * 单机版可以随便搞，在线版不会用到这个东西
 */

public class DSOfflineDataProvider {
    private static final String TAG = DSOfflineDataProvider.class.getName();
    public static final boolean DEV_OFFLINE = false; //开发时有用，控制数据是否走网络渠道

    public static final String JSON_WORK
            = "[{\"id\":1,\"title\":\"哈哈\",\"cover\":\"shdias\",\"front\":0,\"time\":\"2016-05-10 16:08:35.0\",\"viewed\":0,\"template\":1},{\"id\":2,\"title\":\"哈哈\",\"cover\":\"shdias\",\"front\":0,\"time\":\"2016-05-10 16:08:35.0\",\"viewed\":0,\"template\":1},{\"id\":3,\"title\":\"哈哈\",\"cover\":\"shdias\",\"front\":0,\"time\":\"2016-05-10 16:08:35.0\",\"viewed\":0,\"template\":1},{\"id\":4,\"title\":\"哈哈\",\"cover\":\"shdias\",\"front\":0,\"time\":\"2016-05-10 16:08:35.0\",\"viewed\":0,\"template\":1},{\"id\":5,\"title\":\"哈哈\",\"cover\":\"shdias\",\"front\":0,\"time\":\"2016-05-10 16:08:35.0\",\"viewed\":0,\"template\":1}]";
    public static final String JSON_INVESTIGATE
            = "[{\"id\":4,\"title\":\"123\",\"cover\":\"/NewParty/image/back/zzy/1464582052890.jpg\",\"front\":false,\"time\":\"2016-05-30 12:20:36.0\",\"viewed\":0,\"template\":1},{\"id\":3,\"title\":\"123\",\"cover\":\"/NewParty/image/back/zzy/1464247686000.png\",\"front\":false,\"time\":\"2016-05-26 15:27:59.0\",\"viewed\":0,\"template\":2},{\"id\":2,\"title\":\"123\",\"cover\":\"/NewParty/image/back/zzy/1464247188891.png\",\"front\":false,\"time\":\"2016-05-26 15:19:39.0\",\"viewed\":0,\"template\":2}]";
    public static final String JSON_TOPIC
            = "[{\"id\":2,\"title\":\"123\",\"cover\":\"/NewParty/image/back/zzy/1464242251793.png\",\"front\":false,\"time\":\"2016-05-26 13:57:20.0\",\"viewed\":0,\"template\":1},{\"id\":3,\"title\":\"123\",\"cover\":\"/NewParty/image/back/zzy/1464242251793.png\",\"front\":false,\"time\":\"2016-05-26 13:57:20.0\",\"viewed\":0,\"template\":1},{\"id\":4,\"title\":\"123\",\"cover\":\"/NewParty/image/back/zzy/1464242251793.png\",\"front\":false,\"time\":\"2016-05-26 13:57:20.0\",\"viewed\":0,\"template\":1},{\"id\":5,\"title\":\"123\",\"cover\":\"/NewParty/image/back/zzy/1464242251793.png\",\"front\":false,\"time\":\"2016-05-26 13:57:20.0\",\"viewed\":0,\"template\":1},{\"id\":6,\"title\":\"123\",\"cover\":\"/NewParty/image/back/zzy/1464242251793.png\",\"front\":false,\"time\":\"2016-05-26 13:57:20.0\",\"viewed\":0,\"template\":1}]";
    public static final String JSON_DATUM = "";
    public static final String JSON_FIGURE
            = "[{\"id\":22,\"name\":\"阿萨德阿萨德\",\"cover\":\"image/other/person/1463905252725.png\",\"front\":false,\"time\":\"2016-05-12 16:20:47.0\",\"viewed\":0,\"template\":1},{\"id\":21,\"name\":\"fdsa\",\"cover\":\"image/other/person/1463904851526.jpg\",\"front\":false,\"time\":\"2016-05-18 16:13:59.0\",\"viewed\":0,\"template\":1},{\"id\":7,\"name\":\"阿斯蒂芬阿萨德\",\"cover\":\"image/other/1463830947921.jpg\",\"front\":false,\"time\":\"2016-05-18 19:42:18.0\",\"viewed\":0,\"template\":2}]";
    public static final String JSON_STORY = "[{\"id\":12,\"title\":\"撒旦法\",\"cover\":\"image/other/story/1464501809788.png\",\"front\":true,\"time\":\"2016-05-19 14:03:02.0\",\"viewed\":0,\"template\":1},{\"id\":9,\"title\":\"发生as \",\"cover\":\"image/other/story/1463905665046.jpg\",\"front\":true,\"time\":\"2016-05-11 16:27:38.0\",\"viewed\":0,\"template\":1},{\"id\":8,\"title\":\"fdasas\",\"cover\":\"image/other/story/1463905619477.jpg\",\"front\":true,\"time\":\"2016-05-27 16:26:52.0\",\"viewed\":0,\"template\":1},{\"id\":7,\"title\":\"fdsa\",\"cover\":\"image/other/story/1463905463695.jpg\",\"front\":true,\"time\":\"2016-05-27 16:24:19.0\",\"viewed\":0,\"template\":1},{\"id\":6,\"title\":\"的 \",\"cover\":\"image/other/story/1463905411140.jpg\",\"front\":true,\"time\":\"2016-05-19 16:23:25.0\",\"viewed\":0,\"template\":1},{\"id\":5,\"title\":\"飞 \",\"cover\":\"image/other/story/1463905271823.png\",\"front\":true,\"time\":\"2016-05-11 16:21:02.0\",\"viewed\":0,\"template\":1},{\"id\":4,\"title\":\"发生大阿萨德\",\"cover\":\"image/other/story/1463905059539.jpg\",\"front\":true,\"time\":\"2016-05-19 16:17:32.0\",\"viewed\":0,\"template\":1},{\"id\":3,\"title\":\"案发生的as\",\"cover\":\"image/other/story/1463905844013.png\",\"front\":false,\"time\":\"2016-05-25 16:14:30.0\",\"viewed\":0,\"template\":1},{\"id\":2,\"title\":\"大师傅大赛\",\"cover\":\"image/other/story/1463905863672.jpg\",\"front\":false,\"time\":\"2016-05-10 16:08:35.0\",\"viewed\":0,\"template\":2}]";
    public static final String JSON_RESOURCE
            = "";
    public static final String JSON_LIBRARY = "";
    public static final String JSON_WORK_BANNER
            = "";


    public static Object getOfflineData(@RequestType String reqType) throws Exception {
        L.i(TAG, "=>getOfflineData:" + reqType);
        Object o = new Object();
        switch (reqType) {
            case RequestType.TYPE_WORK: {
//                o= getWorkBeen();
                o = DSParser.parse(reqType, JSON_WORK);
            }
            break;

            case RequestType.TYPE_DATUM:
              //  o = DSParser.parse(reqType, JSON_DATUM);
                List<DatumBean> list=new ArrayList<>();
                for(int i=0;i<15;i++){
                    list.add(new DatumBean());
                }
                o=list;
                break;

            case RequestType.TYPE_FIGURE:
                o = DSParser.parse(reqType, JSON_FIGURE);
                break;
            case RequestType.TYPE_INVESTIGATE:
                o = DSParser.parse(reqType, JSON_INVESTIGATE);
                break;
            case RequestType.TYPE_LIBRARY:
                if (JSON_LIBRARY.equals("")) {
                    o = getLibrayBeanList();
                } else
                    o = DSParser.parse(reqType, JSON_LIBRARY);
                break;
            case RequestType.TYPE_RESOURCE:
                if (JSON_LIBRARY.equals("")) {
                    o = getResourceBeanList();
                } else
                o = DSParser.parse(reqType, JSON_RESOURCE);
                break;
            case RequestType.TYPE_STORY:
                o = DSParser.parse(reqType, JSON_STORY);
                break;
            case RequestType.TYPE_TOPIC:
                o = DSParser.parse(reqType, JSON_TOPIC);
                break;
            default: {
                throw new RuntimeException("对应的类型没有找到匹配的返回");
            }
        }
        return o;
    }

    private static List<LibraryBean> getLibrayBeanList() {
        List<LibraryBean> libraryBeen = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            LibraryBean libraryBean = new LibraryBean();
            libraryBean.setTitle("2016年两会：李克强总理记者会");
            libraryBeen.add(libraryBean);
        }
        return libraryBeen;
    }

    private static List<ResourceBean> getResourceBeanList() {
        List<ResourceBean> resourceBeen = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            ResourceBean resourceBean = new ResourceBean();
            resourceBean.setTitle("2016年两会：李克强总理记者会");
            resourceBeen.add(resourceBean);
        }
        return resourceBeen;
    }

    private static List<WorkBean> getWorkBeen() {
        List<WorkBean> workBeen = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            WorkBean workBean = new WorkBean();
            workBean.setTitle("获得了 WorkBean from " + i);
            workBeen.add(workBean);
        }
        return workBeen;
    }


}
